package com.ruoyi.web.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.community.domain.integral.IntDetails;
import com.ruoyi.community.service.integral.IIntDetailsService;
import com.ruoyi.community.service.integral.IIntUserStatisticService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 韩宁 测试controller
 */
@Api("韩宁测试")
@RestController
@RequestMapping("/hn/test")
public class HNTestController {

    @Autowired
    private IIntDetailsService intDetailsService;
    @Autowired
    private IIntUserStatisticService userStatisticService;

    // 增加积分
    // 需要传入 operationId content(操作内容,例如：可口可乐广告，2020年物业费) type(0:支出，1：收入) integral（积分值）
    @ApiOperation("获取新增积分详细")
    @GetMapping("/hello1")
    public Integer hello() {
        IntDetails details = new IntDetails();
        details.setOperationId(1);
        details.setContent("可口可乐广告");
        details.setType(1);
        details.setIntegral(20);
        int i = intDetailsService.insertIntDetails(details);
        return i;
    }

    // 消耗积分
    @ApiOperation("获取新增消费积分详细")
    @GetMapping("/hello2")
    public Integer hello2() {
        IntDetails details = new IntDetails();
        details.setOperationId(1);
        details.setContent("购物抵扣");
        details.setType(0);
        details.setIntegral(200);
        int i = intDetailsService.insertIntDetails(details);
        return i;
    }

    // 查询当前登录用户 传入的 UserID  CommunityId 要从后端获取
    // 查询当前登录用户积分统计信息
    @GetMapping("/hello3")
    public AjaxResult hello3() {
        return AjaxResult.success("查询成功", userStatisticService.selectIntUserStatisticById(SecurityUtils.getUserID(),
                SecurityUtils.getCommunityId()));
    }

}
